package com.wgy.designmode.action.observer;

import com.wgy.designmode.action.observer.observer.Observer;
import com.wgy.designmode.action.observer.observer.Observer_1;
import com.wgy.designmode.action.observer.observer.Observer_2;
import com.wgy.designmode.action.observer.subject.Subject;

/**
 * 观察者模式
 * 使用场景：当一个对象的状态变化需要同时更新其他对象时。
 */
public class ObserverPatternDemo {

    public static void main(String[] args) {

        Subject subject = new Subject();

        Observer observer1 = new Observer_1(subject);
        Observer observer2 = new Observer_2(subject);

        subject.setState(1);



    }
}
